home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ für Kids
/
C++ for kids.iso
/
Buch
/
Befund3a.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1998-12-27
|
2KB
|
73 lines
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Befund3a.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
const String DateiName = "Diagnose.txt";
const String SammelName = "PsychoX.txt";
TForm1 *Form1;
TStringList *Diagnose;
TStringList *Psycho;
int Nr;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
randomize ();
Diagnose = new TStringList;
Psycho = new TStringList;
try
{
Diagnose->LoadFromFile (DateiName);
}
catch (...)
{
Diagnose->Add ("Keine Sprechstunde");
}
ScrollBar1->Min = 0;
ScrollBar1->Max = Diagnose->Count - 1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Panel1->Caption = "";
Edit1->Text = "";
Edit1->SetFocus ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Psycho->Add (Edit1->Text);
Nr = random (Diagnose->Count);
Panel1->Caption = Diagnose->Strings[Nr];
Psycho->Add (Panel1->Caption);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ScrollBar1Change(TObject *Sender)
{
Panel1->Caption = Diagnose->Strings[ScrollBar1->Position];
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
try
{
Psycho->SaveToFile (SammelName);
}
catch (...)
{
Application->MessageBox
("Fehler beim Speichern der Datei!", "Achtung!", 0+48);
}
}
//---------------------------------------------------------------------------